﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LearnCSharp
{
    /*
     * *************************************************************************************
     * *************************************************************************************
     *                                      STRUCTURE
     * *************************************************************************************
     * *************************************************************************************
    */

    struct Pers
    {
        public string Nom;
        public int Age;
    }

    /// <summary>StructureCSharp</summary>
    public class StructureCSharp
    {
        /// <summary> Nom </summary>
        public string Nom;
        /// <summary> Age </summary>
        public int Age;

        private void UseStruture()
        {
            //Pers p;            
            //Console.WriteLine("Personne : {0}, {1}", p.Nom, p.Age);

            Pers p1;
            p1.Nom = "Yannick";
            p1.Age = 32;
            Console.WriteLine("Personne : {0}, {1}", p1.Nom, p1.Age);

            Pers p2 = new Pers();
            Console.WriteLine("Personne : {0}, {1}", p2.Nom, p2.Age);

            Console.ReadLine();
        }

        private void DiffClassEtStruc()
        {
            StructureCSharp C1 = new StructureCSharp();
            C1.Nom = "Yannick";
            C1.Age = 32;
            Console.WriteLine("Classe C1: {0}, {1}", C1.Nom, C1.Age);

            StructureCSharp C2 = new StructureCSharp();
            C2.Nom = "Mathieu";
            C2.Age = 29;
            Console.WriteLine("Classe C2: {0}, {1}", C2.Nom, C2.Age);

            Pers S1 = new Pers();
            S1.Nom = "Myriam";
            S1.Age = 28;
            Console.WriteLine("Struct S1 : {0}, {1}", S1.Nom, S1.Age);

            Pers S2 = new Pers();
            S2.Nom = "Muriel";
            S2.Age = 58;

            Console.WriteLine("Struct S2 : {0}, {1}", S2.Nom, S2.Age);

            C1 = C2;
            C2.Nom = "Michel";
            C2.Age = 62;
            Console.WriteLine(" Classe : C1 = C2, C2 change,  C1: {0}, {1} : COPIE PAR REFERENCE", C1.Nom, C1.Age);

            S1 = S2;
            S2.Nom = "Margaret";
            S2.Age = 62;
            Console.WriteLine(" Struct : S1 = S2, S2 change, S1: {0}, {1} : COPIE PAR VALEUR", S1.Nom, S1.Age);


            Console.ReadLine();
        }
    }
}
